<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Gets value</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="reflectionproperty.getname.html">ReflectionProperty::getName</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="reflectionproperty.isdefault.html">ReflectionProperty::isDefault</a></div>
 <div class="up"><a href="class.reflectionproperty.html">ReflectionProperty</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="reflectionproperty.getvalue" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ReflectionProperty::getValue</h1>
  <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">ReflectionProperty::getValue</span> &mdash; <span class="dc-title">Gets value</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-reflectionproperty.getvalue-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><strong>ReflectionProperty::getValue</strong></span>
    ([ <span class="methodparam"><span class="type">object</span> <code class="parameter">$object</code></span>
  ] )</div>

  <p class="para rdfs-comment">
   Gets the properties value.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-reflectionproperty.getvalue-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">object</code></em></dt>

     <dd>

      <p class="para">
       If the property is non-static an object must be provided to fetch the
       property from. If you want to fetch the default property without
       providing an object use <span class="methodname"><a href="reflectionclass.getdefaultproperties.html" class="methodname">ReflectionClass::getDefaultProperties()</a></span>
       instead.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-reflectionproperty.getvalue-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   The current value of the property.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-reflectionproperty.getvalue-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   Throws a <a href="class.reflectionexception.html" class="classname">ReflectionException</a> if the property is inaccessible.
   You can make a protected or private property accessible using
   <span class="methodname"><a href="reflectionproperty.setaccessible.html" class="methodname">ReflectionProperty::setAccessible()</a></span>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-reflectionproperty.getvalue-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5144">
    <p><strong>Example #1 <span class="methodname"><strong>ReflectionProperty::getValue()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">Foo&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;static&nbsp;</span><span style="color: #0000BB">$staticProperty&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'foobar'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;</span><span style="color: #0000BB">$property&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'barfoo'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;</span><span style="color: #0000BB">$privateProperty&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'foofoo'</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">$reflectionClass&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">ReflectionClass</span><span style="color: #007700">(</span><span style="color: #DD0000">'Foo'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$reflectionClass</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getProperty</span><span style="color: #007700">(</span><span style="color: #DD0000">'staticProperty'</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">getValue</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$reflectionClass</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getProperty</span><span style="color: #007700">(</span><span style="color: #DD0000">'property'</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">getValue</span><span style="color: #007700">(new&nbsp;</span><span style="color: #0000BB">Foo</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$reflectionProperty&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$reflectionClass</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getProperty</span><span style="color: #007700">(</span><span style="color: #DD0000">'privateProperty'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$reflectionProperty</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setAccessible</span><span style="color: #007700">(</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$reflectionProperty</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getValue</span><span style="color: #007700">(new&nbsp;</span><span style="color: #0000BB">Foo</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
string(6) &quot;foobar&quot;
string(6) &quot;barfoo&quot;
string(6) &quot;foofoo&quot;
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-reflectionproperty.getvalue-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="reflectionproperty.setvalue.html" class="methodname" rel="rdfs-seeAlso">ReflectionProperty::setValue()</a> - Set property value</span></li>
    <li class="member"><span class="methodname"><a href="reflectionproperty.setaccessible.html" class="methodname" rel="rdfs-seeAlso">ReflectionProperty::setAccessible()</a> - Set property accessibility</span></li>
    <li class="member"><span class="methodname"><a href="reflectionclass.getdefaultproperties.html" class="methodname" rel="rdfs-seeAlso">ReflectionClass::getDefaultProperties()</a> - 获取默认属性</span></li>
    <li class="member"><span class="methodname"><a href="reflectionclass.getstaticpropertyvalue.html" class="methodname" rel="rdfs-seeAlso">ReflectionClass::getStaticPropertyValue()</a> - 获取静态（static）属性的值</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="reflectionproperty.getname.html">ReflectionProperty::getName</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="reflectionproperty.isdefault.html">ReflectionProperty::isDefault</a></div>
 <div class="up"><a href="class.reflectionproperty.html">ReflectionProperty</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
